import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:netease_music/main.dart';
import 'package:provider/provider.dart';

class CategoryNavigationBar extends StatelessWidget {
  final Widget child;

  const CategoryNavigationBar(this.child, {super.key});

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Container(
          color: Colors.white.withOpacity(0.2),
          width: 100,
          child: Center(
            child: Column(
              children: [
                Align(
                  child: Container(
                    decoration: const BoxDecoration(
                      shape: BoxShape.circle,
                    ),
                    clipBehavior: Clip.hardEdge,
                    child: Image.asset(
                      'assets/images/logo.jpg',
                      height: 60,
                      width: 60,
                    ),
                  ),
                ),
                Expanded(
                  child: ListView.builder(
                    itemBuilder: (c, i) {
                      String title =
                          context.read<CurrentProvider>().naviList[i];
                      return ListTile(
                        title: MouseRegion(
                          child: GestureDetector(
                            onTap: () {
                              if (i == 0) {
                                context.push('/1');
                              } else if (i == 1) {
                                context.push('/');
                              } else if (i == 2) {
                                context.push('/todayPlaylist');
                              }
                            },
                            child: Text(title),
                          ),
                        ),
                      );
                    },
                    itemCount: context.watch<CurrentProvider>().naviList.length,
                  ),
                ),
              ],
            ),
          ),
        ),
        Expanded(child: child)
      ],
    );
  }
}
